package ps.net;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;



public class LoginContent implements PacketContent {

    byte[] authId;
    int version;
    
    LoginContent() {
    }
    
    public LoginContent(byte[] authId, int version) {
        this.authId = authId;
        this.version = version;
    }
    
    @Override
    public void writeContent(OutputStream out) throws IOException {
        // write authId (16 bytes)
        out.write(authId);
        
        // write version
        Packet.write2ByteNumber(out, version);
    }
    
    @Override
    public void readContent(InputStream in) throws IOException {
        authId = new byte[16];
        
        // read auth id
        in.read(authId);
        
        // read version
        version = Packet.read2ByteNumber(in);
        
    }
    
    @Override
    public String toString() {
        String ret = "[ Auth |";
        ret += " authId=\"";
        for (int i = 0; i < authId.length; i++) {
            ret += authId[i] + ";";
        }
        ret += " version=\"" + version + "\"";
        ret += " \" ]";
        return ret;
    }

    public byte[] getAuthId() {
        return authId;
    }

    public void setAuthId(byte[] authId) {
        this.authId = authId;
    }

    public int getVersion() {
        return version;
    }
    
    public void setVersion(int version) {
        this.version = version;
    }
    
    
}
